package com.zp.crm.service.JwjlService.Impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.zp.crm.dao.JwjlDao.JwjlDao;
import com.zp.crm.dto.Jwjl.JwjlDto;
import com.zp.crm.entity.JwjlEntity.JwjlEntity;
import com.zp.crm.service.JwjlService.JwjlService;
import com.zp.crm.util.targetLog.Log;
@Service("jwjlService")
public class JwjlServiceImpl implements JwjlService{
	@Resource
	public JwjlDao jDao;
	@Log(name="根据编号查询交往记录")
	@Override
	public Map<String, Object> selectCode(String code) {
		
		List<JwjlEntity> list=jDao.selectCode(code);
		
		String a=new JwjlDto().Html(list);
		
		Map<String, Object> map=new HashMap<>();
		
		map.put("message", a);
		
		return map;
	}
	@Log(name="添加客户的交往记录")
	@Override
	public Map<String, Object> insert(JwjlEntity entity) {
		
		Map<String, Object> map=new HashMap<>();
		
		int r=jDao.insert(entity);
		
		if(r>0){
			map.put("success", true);
			map.put("message", "添加成功！");
		}else{
			map.put("success", false);
			map.put("message", "添加失败！");
		}
		
		return map;
	}
	@Log(name="删除客户的交往记录 ")
	@Override
	public Map<String, Object> delete(int id) {
		Map<String, Object> map=new HashMap<>();
		
		int r=jDao.delete(id);
		
		if(r>0){
			map.put("success", true);
			map.put("message", "删除成功！");
		}else{
			map.put("success", false);
			map.put("message", "删除失败！");
		}
		
		return map;
	}
}
